//礼物飘屏ui
import 'package:flutter/material.dart';

import '../../lib_basemodel/chat_room/flyScreen/flying_data.dart';
import 'builder/box_open_builder.dart';
import 'builder/common_content_builder.dart';
import 'builder/gift_floating_content_builder.dart';

class GiftFloatingScreen extends StatelessWidget {
  final FlyingData data;

  GiftFloatingScreen({Key? key, required this.data}) : super(key: key);

  List<GiftFloatingContentBuilder> contentBuilders = [
    BoxOpenBuilder(),

    /// 这个builder，始终放在最后一个
    CommonContentBuilder(),
  ];

  @override
  Widget build(BuildContext context) {
    GiftFloatingContentBuilder builder = contentBuilders.firstWhere(
        (element) => element.match(data),
        orElse: () => contentBuilders.last);
    return builder.build(context, data);
  }
}
